package com.lzq.job;

import org.quartz.*;
import org.quartz.impl.StdSchedulerFactory;

import java.util.GregorianCalendar;

public class helloQuarzt {
    public static void main(String[] args) throws SchedulerException {
        //调度器
        Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();

        //触发器
        SimpleTrigger trigger = TriggerBuilder.newTrigger().withIdentity("trigger1","group1")
                .startNow()
                .withSchedule(SimpleScheduleBuilder.simpleSchedule().withIntervalInSeconds(2).repeatForever())
                .endAt(new GregorianCalendar(2020,8,9,10,02,01).getTime())
                .build();

        //jobDetail
        JobDetail jobDetail = JobBuilder.newJob(helloJob.class).withIdentity("job1","group1").build();

        //将jobDetail和触发器增加到调度器中
        scheduler.scheduleJob(jobDetail,trigger);

        //启动
        scheduler.start();


    }
}
